<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../../css/aui.css" />
    <style>
        body {}
    </style>
</head>

<body>
    <header class="aui-bar aui-bar-nav" onclick="handleback()" tapmode>
        <div class="aui-pull-left aui-btn">
            <span class="aui-iconfont aui-icon-left"></span>
        </div>
        <div class="aui-title">材料管理</div>
    </header>
    <ul class="aui-list aui-media-list" id="list">
    </ul>
</body>
<script type="text/javascript" src="../../../script/api.js"></script>
<script type="text/javascript" src="../../../script/doT.min.js"></script>
<script type="text/template" id="templist">
  {{~it:value:index}}
  <li class="aui-list-item aui-list-item-arrow" onclick="checodetail('{{=value.id}}')">
      <div class="aui-media-list-item-inner">
          <div class="aui-list-item-inner">
              <div class="aui-list-item-text">
                  <div class="aui-list-item-title">{{=value.project_name}}</div>
                  <div class="aui-list-item-right">{{=value.update_time}}</div>
              </div>
              <div class="aui-list-item-text aui-ellipsis-2">
                  {{=value.remark}}
              </div>
          </div>
      </div>
  </li>
  {{~}}
</script>
<script type="text/javascript">
    var token = $api.getStorage('token');
    var uid = $api.getStorage('uid');

    apiready = function() {
        init()
    };
    var init = function() {
        api.ajax({
            url: $api.SERVE_URL + 'index.php/index/Material/index',
            method: 'post',
            headers: {"token": token},
            data: {
                values: {
                    'limit': 20,
                    'material_name': "",
                    'pid': "",
                    'state': "",
                    'token_uid': uid
                }
            }
        }, function(ret, err) {
            if (ret) {
                if (ret.code === 200) {
                  var data = ret.data.list;
                  var temptxt = doT.template($api.byId('templist').innerHTML);
                  $api.byId('list').innerHTML = temptxt(data);
                } else if (ret.code === 401) {

                } else  {

                }
            } else {
                // console.log(JSON.stringify(err));
                api.toast({
                    msg: err.msg,
                    duration: 2000,
                    location: 'top'
                });

            }
        });

    }

    var handleback = function () {
      api.closeWin({
          name: 'matlist'
      });

    }

    var checodetail = function (id) {
      api.openWin({
          name: 'db',
          url: '../../main/detail/index.html',
          pageParam: {
            id: id
          }
      });

    }
</script>

</html>
